package com.ktjiaoyu.repository;

import com.ktjiaoyu.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface UserRepository extends JpaRepository<User,Long>,
        JpaSpecificationExecutor<User> {

//    @Query("FROM User WHERE usrRoleId = ?1 ")
//    @Query("FROM User WHERE usrRoleId = :roleId ")
//    public List<User> findUserByRoleId(@Param("roleId") Long roleId);

    @Query(value="SELECT * FROM `sys_user` WHERE `usr_role_id` = ?1 "
    ,nativeQuery=true)
    public List<User> findUserByRoleId(Long roleId);

    //等值查询
    public List<User> findByUsrName(String usrName);

    //模糊匹配
    public List<User> findByUsrNameLike(String usrName);

    //多条件查询
    public List<User> findByUsrNameAndUsrPassword(String usrName,String usrPassword);
}
